import 'package:flutter/material.dart';
import 'package:flutter_base/provider_demo2/models/counter_model.dart';
import 'package:provider/provider.dart';

class FirstPage extends StatefulWidget {
  const FirstPage({super.key});

  @override
  State<FirstPage> createState() => _FirstPageState();
}

class _FirstPageState extends State<FirstPage> {
  @override
  Widget build(BuildContext context) {
    final cm = Provider.of<CounterModel>(context);
    return Scaffold(
      appBar: AppBar(title: const Text('一级页面')),
      body: Column(
        children: [
          Text('Counter: ${cm.counter}'),
          TextButton(
              onPressed: () {
                Navigator.of(context).pushNamed('second_age');
              },
              child: const Text('进入二级页面')),
        ],
      ),
    );
  }
}
